#ifndef _NUMBERGENERATORSCREEN_H_
# define _NUMBERGENERATORSCREEN_H_

# include <SDL/SDL.h>
# include <vector>
# include <map>
# include "Utils\IScreen.h"
# include "Utils\ScreenManager.h"
# include "Utils\Surface.h"
# include "MyScreenArgs.h"
# include "constantes.h"
# include "Elements\PushButton.h"
# include "Elements\Label.h"
# include "Utils\Font.h"
# include "NumberGenerator.h"
# include "APopUpScreen.h"

struct NumberGeneratorArgs : public MyScreenArgs
{
public:
	NumberGeneratorArgs(SDL_Surface* _screen, SDL_Event* _event);
	virtual ~NumberGeneratorArgs();
};

class NumberGeneratorScreen;

typedef bool (NumberGeneratorScreen::*ButtonAction)(SDL::UTILS::IArgs*, SDL::ELEMENTS::AButton*);

class NumberGeneratorScreen : public SDL::UTILS::IScreen
{
public:
	static std::string const PATH;

private:
	SDL::UTILS::Surface m_surface;
	std::vector<SDL::ELEMENTS::AElement*> m_elements;
	std::map<SDL::ELEMENTS::AElement*, ButtonAction> m_actions;
	SDL::UTILS::Font m_font;
	SDL::ELEMENTS::Label* m_possibilitiesLabel;
	SDL::ELEMENTS::Label* m_timeLabel;
	SDL::ELEMENTS::Label* m_nbLabel;
	SDL::ELEMENTS::PushButton* m_pbStart;
	SDL::ELEMENTS::PushButton* m_pbStop;
	SDL::ELEMENTS::PushButton* m_pbBack;
	SDL::ELEMENTS::PushButton* m_pbHelp;
	SDL::ELEMENTS::Label* m_valueLabel;
	NGConfig m_config;
	NumberGenerator* m_generator;
	APopUpScreen* m_popUpScreen;
	PopUpArgs* m_popUpArgs;
	SDL::ELEMENTS::Label* m_timerLabel;

public:
	NumberGeneratorScreen();
	virtual ~NumberGeneratorScreen();

	virtual void Draw(SDL::UTILS::IArgs* _args);
	virtual void Exec(SDL::UTILS::IArgs* _args);
	static bool Manage(SDL::UTILS::ScreenManager::Element* _caller, SDL::UTILS::IArgs* _arg);

private:
	void InitElements();
	void UpdateConfigLabels();
	void Start();
	void Stop();
	void Reset();
	void ShowResultScreen();
	void UpdateTimer(int _seconds);

	bool On_pbPossibilitiesMinus_Clicked(SDL::UTILS::IArgs* _datas, SDL::ELEMENTS::AButton* _button);
	bool On_pbPossibilitiesPlus_Clicked(SDL::UTILS::IArgs* _datas, SDL::ELEMENTS::AButton* _button);
	bool On_pbTimeMinus_Clicked(SDL::UTILS::IArgs* _datas, SDL::ELEMENTS::AButton* _button);
	bool On_pbTimePlus_Clicked(SDL::UTILS::IArgs* _datas, SDL::ELEMENTS::AButton* _button);
	bool On_pbNbMinus_Clicked(SDL::UTILS::IArgs* _datas, SDL::ELEMENTS::AButton* _button);
	bool On_pbNbPlus_Clicked(SDL::UTILS::IArgs* _datas, SDL::ELEMENTS::AButton* _button);
	bool On_pbStart_Clicked(SDL::UTILS::IArgs* _datas, SDL::ELEMENTS::AButton* _button);
	bool On_pbStop_Clicked(SDL::UTILS::IArgs* _datas, SDL::ELEMENTS::AButton* _button);
	bool On_pbBack_Clicked(SDL::UTILS::IArgs* _datas, SDL::ELEMENTS::AButton* _button);
	bool On_pbHelp_Clicked(SDL::UTILS::IArgs* _datas, SDL::ELEMENTS::AButton* _button);
};

#endif // _NUMBERGENERATORSCREEN_H_
